package com.abc.service;

import com.abc.bean.Doctor;
import com.abc.bean.Patient;
import com.abc.mapper.DoctorMapper;
import com.abc.mapper.PatientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: bc
 * @Date: 2024-11-17 12:37
 * @Description:
 */
@Service
public class DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;
    public List<Doctor> selectDoctor(String doctorName){
        return doctorMapper.selectDoctor(doctorName);
    }

    public List<Doctor> selectAllDoctor(){
        return doctorMapper.selectAllDoctor();
    }

    public String addDoctor(Doctor doctor){
        if(doctorMapper.selectOneDoctorByDoctorId(doctor.getDoctorId())!=null){
            return "医生编号重复，添加失败";
        }
        return doctorMapper.addDoctor(doctor) > 0 ? "添加成功" : "添加失败";
    }
    public int deleteDoctor(String id){
        return doctorMapper.deleteDoctor(id);
    }
    public Doctor selectOneDoctorById(String id){
        return doctorMapper.selectOneDoctorById(id);
    }
    public int updateDoctorById(Doctor doctor){
        return doctorMapper.updateDoctorById(doctor);
    }
}
